<?php
namespace Tbf\Component\Http\Tests;
use Symfony\Component\HttpFoundation\Response;
use Tbf\Bundle\TestBundle\TestSuite\TbfTestCase;
use Tbf\Component\Http\SymfonyHttpFunction;

class SymfonyHttpFunctionTest extends TbfTestCase{
    function testAddAttachHeaderToResponse(){
        $resp = new Response();
        SymfonyHttpFunction::addAttachmentHeader($resp);
        $this->assertEquals('attachment',$resp->headers->get('Content-Disposition'));

        $resp = new Response();
        SymfonyHttpFunction::addAttachmentHeader($resp,'application/json');
        $this->assertEquals('attachment',$resp->headers->get('Content-Disposition'));
        $this->assertEquals('application/json',$resp->headers->get('Content-type'));

        $resp = new Response();
        SymfonyHttpFunction::addAttachmentHeader($resp,'test/json','1990-01-01_01-01-01.json');
        $this->assertEquals('attachment;filename="1990-01-01_01-01-01.json"',$resp->headers->get('Content-Disposition'));
        $this->assertEquals('application/json',$resp->headers->get('Content-type'));
    }
}